// pages/user/temp/temp.js
const api = require("../../../apis/modules/staff")
Page({
  /**
   * 页面的初始数据
   */
  data: {
    activityList: [],
    windowHeight: '',
    userType:["","常住","租户","访客"],
    inType:["离开社区","进入社区"],
      pageNumber:0,
      pageSize:10,
      household:1,
      total: 0,
      keyword:''
  },
  input: function(e) {
    this.setData({ activityList: [], pageNumber: 0, household: 1, pageSize: 10,keyword: e.detail.value });
    this.load();
},
scrollMoreServiceList(){
  this.data.pageNumber++;
  if (this.data.pageNumber >= this.data.total) {
    wx.showToast({
      title: '暂无更多数据',
      icon:'none'
    });
    return
  }
  wx.showToast({
    title: '加载中'
  });
  this.load()
},

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.getSystemInfo({
      complete: (res) => {
        this.setData({
          windowHeight: res.screenHeight - ((res.screenWidth / 750) * 2 * (49)) - res.statusBarHeight-50
        })

      },
    })
  this.load()
  },
load(){
  var parma={
    pageNumber:this.data.pageNumber,
    pageSize:this.data.pageSize,
    household:this.data.household,
    keyword:this.data.keyword
  }
  api.userHealthInfoList(parma).then(res=>{
    if(res.resultCode==0){
      for(var index  in res.data.content){
        res.data.content[index] .personType = this.data.userType[res.data.content[index] .personType]
        res.data.content[index].inOrOut = this.data.inType[res.data.content[index].inOrOut]
      }
      this.setData({
        activityList:res.data.content,
        pageNumber:res.data.pageNumber,
        pageSize:res.data.pageSize,
        total: res.data.totalPages
      })
    }
  })
},

getData(pageNum = 1, pageSize = 10) {
  let that = this;
  wx.showLoading({
    title: '加载中',
  })
  parma.pageNum = pageNum;
  parma.pageSize = pageSize;

  yyrequset.getAllEvent(parma).then(res => {
    var renderData = res.data.data;
    var colorList = statusData.colorList;

    for (var index in renderData) {
      for (var item of colorList) {
        if (renderData[index].status == item.status) {
          renderData[index].nowColor = item.color
         
        }
        renderData[index].startTime =  renderData[index].startTime.substr(0,renderData[index].startTime.length-1)
      }
    }
    that.setData({
      activityList: that.data.activityList.concat(renderData),
      total: res.data.total
    })
    wx.hideLoading();
  })
},
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})